<?php 
//if (! defined('BAEPATH')) exit('No direct script access allowed');           
class NewDoc extends MY_Controller {

    //constructor
     function __construct()
     {                                                                   
        parent::__construct();              
        $this->load->helper('form'); 
        $this->view_data['selectedmenu']='newdoc';
        $this->content_view='v_newDoc';
      }

    public function index()
    {       
         $this->NewDocument();
    }
    function NewDocument()
    {
        $docTypes = Doc_type::all();
        $this->view_data['docTypes'] = $docTypes;
        
        $docGroups = Doc_group::all();
        $this->view_data['docGroups'] = $docGroups;
        
        $dept = Department::all();
        $this->view_data['dept'] = $dept;
    }
    function ShowDocument()
    {
        $this->ClearContent();
        $doc = Doc_type::all();
                                         
        $dept = Department::all();

        $DocGroups = Doc_group::all();
        $users = User::all();
        
                                        
        
/*        foreach($DocGroups as $docGroup)
        {
            echo 'group->department:'.$docGroup->department->depart_name.'<br/>';  
        } */
        $depart = 'department';
        $fieldname = 'depart_name';
        foreach($DocGroups as $docGroup)
        {
             echo 'group->department:'.$docGroup->{$depart}->{$fieldname}.'<br/>';        
        }        
        return ;
        echo '<pre>';
        
        print_r($users);
        
        $dept = Department::all();
        
    }

    function LoadUser()
    {
        $users = User::all();
        $this->view_data['users']=$users;
        $this->view_data['selectedmenu']='user';
        
    }
    public function ShowUserProfile()
    {
                                                                
        if($this->user)
        {                                                       
            $depart = Department::all();            
            $this->view_data['user'] = $this->user;      
            $this->view_data['departments'] = $depart;      
        }
        else
            echo 'cannot file user profile for user '.$this->user->user_id;        
    }
  
    public function Logout()
    {
        User::Logout();
        echo 'loggout';
        redirect(base_url());
    }
}/* End of class */

?>